{extend name="../layout/base"}
{block name="tool_bar"}
<form class="layui-form search-form" action="">
    <div class="layui-row layui-col-space10">

        <div class="layui-col-xs2">
            <div class="layui-form-item">
                <select name="type" lay-filter="types">
                    <option {if $type==''} selected {/if} value="">所有</option>
                    <option {if $type=='mp'} selected {/if} value="mp">公众号</option>
                    <option {if $type=='mini'} selected {/if} value="mini">小程序</option>
                </select>
            </div>
        </div>
        <div class="layui-col-xs2">
            <div class="layui-form-item">
                <select name="status" lay-filter="status" lay-verify="required">
                    <option {if $status==-1} selected {/if} value="-1">状态</option>
                    <option {if $status==1} selected {/if} value="1">开启</option>
                    <option {if $status==0} selected {/if} value="0">关闭</option>
                </select>
            </div>
        </div>
        <div class="layui-col-xs6">
            <div class="layui-col-xs5" style="margin-left: 5px; line-height: 38px;">
                <div class="layui-form-item">
                    <input name="search_key"
                           placeholder="请输入关键词"
                           value="{$search_key}"
                           class="layui-input"
                           type="text">
                </div>
            </div>
            <div class="layui-col-xs4" style="margin-left: 5px; line-height: 38px;">
                <button class="layui-btn layui-btn-primary" lay-submit="" lay-filter="formDemo">
                    <i class="fa fa-search"></i>
                </button>
            </div>
        </div>
        <div class="layui-col-xs2 tr">
            <a href="{:url('apps')}" class="layui-btn layui-btn-sm">更多应用</a>
        </div>

    </div>
</form>
{/block}
{block name="body"}
<div>
    <div class="layui-row">
        <div id="app-body">
            <div id="apps">
                <form class="layui-form" action="">
                    <div class="layui-row">
                        {volist name="data_list" id="v"}
                        <div class="layui-col-xs4 apps-volist">
                            <div class="apps-volists">
                                <div class="apps-icon">
                                    <img src="{$v.logo}">
                                </div>
                                <div class="app-desc">
                                    <h2>
                                        {$v.name}
                                        <!--<span class="apps-money layui-badge layui-bg-blue">{if $v.type =='mp'}公众号{else /}小程序{/if}</span>-->
                                    </h2>
                                    <div class="app-desc-body">
                                        <div class="description">{:mb_substr($v.desc,0,16)}</div>
                                        <div class="tr">
                                            {if time() + 259200 > $v.deadline}
                                            <span class="layui-badge layui-bg-danger overtime-tip">{:date('Y-m-d H:i', $v.deadline)}到期</span>
                                            {/if}
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-row">
                                    <div class="layui-col-xs6 tc app-opr">
                                        <a href="{$v['admin_url']}"
                                           style="margin-top: 8px;"
                                           class="layui-btn layui-btn-xs">&nbsp;管理&nbsp;</a>
                                    </div>
                                    <div class="layui-col-xs6 tc app-opr">
                                        <input
                                                type="checkbox"
                                                name="status{$v.id}"
                                                lay-filter="status"
                                                lay-skin="switch"
                                                lay-text="开启|关闭"
                                                value="{$v.admin_addon_id}"
                                                {if $v.status}checked{/if}
                                        >
                                    </div>
                                </div>
                            </div>
                        </div>
                        {/volist}
                    </div>
                </form>
            </div>
        </div>
        <div id="page">{$page|raw}</div>
    </div>
</div>
{/block}

{block name="js"}
<script>
    layui.use(['layer','form'], function() {
        var layer = layui.layer
            ,form = layui.form;
        //form.render();
        form.on('select(types)', function(data){
            $('.search-form').submit();
        });
        form.on('select(status)', function(data){
            $('.search-form').submit();
        });
        form.on('switch(status)', function(data){
            var loadingIndex = layer.load(1);
            $.post('', {id: data.value}, function (res) {
                layer.close(loadingIndex);
                if(res.code !== 1){
                    layer.alert(res.msg);
                }
            });
        });
    });
</script>
{/block}

{block name="css"}
<style>
    .apps-volists{padding: 0;}
    .apps-icon,.app-desc{padding: 5px;}
    .overtime-tip{float: left;}
    .app-opr{border: 1px solid #F2F2F2;border-left: none;border-bottom: none;padding-bottom: 8px;}
    .app-opr:last-child{border-right: none;}
</style>
{/block}